#ifndef FTBITMAPFONT_H_
#define FTBITMAPFONT_H_

class FTBitmapChar;
class FontAtlas;
class GLCallBatcher;

#include <GlobalData.h>
#include <map>
#include <string>

class FTBitmapFont
{
private:
	int                                 lineHeight;
	std::map<wchar_t, FTBitmapChar*> 	mapBitmapChar;
	FontAtlas                           *fontAtlas;
	struct FT_FaceRec_                  *face;

public:
    bool                                smooth;

private:
	void ReleaseFace();

public:
	FTBitmapFont(FontAtlas* fontAtlas);
	~FTBitmapFont();
    
	void    init();
	void    release();
	void    load(const std::string& fileName);
	void    finishCreating();
	int     getCharWidth(wchar_t character);
	int     getWidth(const wchar_t* text);
    
	int     drawString(int x, int y, const wchar_t* text, float scale = 1.0f);
	int     getHeight() const                               { return lineHeight; }
	void    setLineHeight(int lineHeight)                   { this->lineHeight = lineHeight; }
	void    addChar(int charCode, FTBitmapChar* bitmapChar) { this->mapBitmapChar[charCode] = bitmapChar; }
	void    setFTFace(struct FT_FaceRec_* Face)             { this->face = Face; }
    
	FTBitmapChar* GetChar(wchar_t charCode)
	{
        std::map<wchar_t, FTBitmapChar*>::const_iterator iter;
		iter = mapBitmapChar.find(charCode);
		if (iter != mapBitmapChar.end()) 
			return iter->second;
		return NULL;
	}
};

#endif /*FTBITMAPFONT_H_*/
